package com.yzj.android.dao.impl;

import com.yzj.Bean.Order;
import com.yzj.android.dao.BaseDao;
import com.yzj.android.dao.OrderDao;

import java.util.List;

public class OrderDaoImpl extends BaseDao implements OrderDao {
    @Override
    public int addOrderItem(Order order) {

        String sql =" INSERT INTO `order`(`id`,`name`,`item_name`,`items_price`,`items_pic`,`items_status`) VALUE(?,?,?,?,?,?)";
        return update(sql,order.getId(),order.getName(),order.getItem_name(),order.getItems_price(),order.getItems_pic(),order.getItems_status());



    }

    @Override
    public int updateOrdItem(int id, String username) {

        String sql = "update `order` set `items_status`=1  where `id` = ? and `name` = ?";
        return update(sql,id,username);

    }

    @Override
    public List<Order> orderList() {

        String sql = "select id, `name` ,item_name,items_price,items_pic,items_status from `order`";
        return queryForList(Order.class,sql);
    }

    @Override
    public List<Order> myOrders(String name) {
        String sql = "select id, `name` ,item_name,items_price,items_pic,items_status from `order` where  `name` =? ";
        return queryForList(Order.class,sql,name);

    }
}
